package com.allwees.bs.c.module.order.dto;

import com.allwees.bs.c.module.order.entity.OrderReviewItemEntity;
import com.allwees.core.common.util.reflect.PojoUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 订单项评价
 *
 * @author jy2016
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel
public class OrderReviewItemDTO implements Serializable {

	private String uuid;

	private String orderUuid;

	// 订单评价
	private String orderReviewUuid;

	// user
	private String userUuid;

	// User Email
	private String userEmail;

	// User名
	private String userFirstName;

	// User姓
	private String userLastName;

	//User头像
	private String userAvatar;

	//User手机号
	private String userPhone;

	//User语言
	private String userLanguage;

	//User国家
	private Integer userCountry;

	//产品ID
	private String productUuid;

	//SKU ID
	private String skuUuid;

	//状态
	private Integer status;

	//评分1到5
	private Integer rating;

	//评价内容
	private String text;

	//图片
	private List<String> photos;

	private Date createdAt;

	public OrderReviewItemDTO(OrderReviewItemEntity entity) {
		this();
		PojoUtil.copy(this, entity, "id", "productUuid", "skuUuid", "status", "rating", "text", "orderUuid", "orderReviewUuid", "userUuid",
				"userEmail", "userFirstName", "userLastName", "userAvatar", "userPhone", "userLanguage", "userCountry");
		this.createdAt = entity.getCreatedAt();
		String photos = entity.getPhotos();
		if(Objects.nonNull(photos)) {
			this.photos = Arrays.asList(photos.split(","));
		}
	}
}
